package com.qf.xiaomi.service.impl;

import com.qf.xiaomi.dao.GoodsDao;
import com.qf.xiaomi.dao.impl.GoodsDaoImpl;
import com.qf.xiaomi.pojo.TbGoods;
import com.qf.xiaomi.pojo.TbGoodsType;
import com.qf.xiaomi.pojo.pageBean;
import com.qf.xiaomi.service.GoodsService;

import java.util.ArrayList;
import java.util.List;

public class GoodsServiceImpl implements GoodsService {
    GoodsDao dao = new GoodsDaoImpl();

    @Override
    public pageBean  selectPage(long id,pageBean page) {
        return dao.selectPage(id,page);
    }

    @Override
    public TbGoods selectByGoodId(long GoodsId) {
        return dao.selectByGoodsId(GoodsId);
    }

    @Override
    public List<TbGoods> findGoods() {
        List<TbGoods> tbGoods = new ArrayList<>();
        tbGoods=dao.findGoods();
        for (int i = 0; i < tbGoods.size(); i++) {

            TbGoodsType goodsType= dao.findByTid(tbGoods.get(i).getTypeid());
           tbGoods.get(i).setTypeName(goodsType.getName());
        }
        return tbGoods;
    }
//    @Override
//    public List<TbGoods> selectByGoodsId(Long typeId) {
//        return dao.selectByGoodsId(typeId);
//    }
}
